#include <memory>
#include <chrono>
#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/twist.hpp"
using namespace std;

class Turtlecircle : public rclcpp::Node
{
public:

    Turtlecircle(const string& name) :Node(name)
    {
        _publisher = create_publisher<geometry_msgs::msg::Twist>("/turtle1/cmd_vel", 10);
        _timer = create_wall_timer(1000ms, [&]()
                                   {
             auto msg = geometry_msgs::msg::Twist();
            msg.linear.x = 1.0;
            msg.angular.z = 0.5;
            _publisher->publish(msg); });
    }

private:
    // 定时器智能指针
    rclcpp::TimerBase::SharedPtr _timer; 
    // 发布者智能指针
    rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr _publisher;
};



int main(int argc, char** argv)
{
    rclcpp::init(argc, argv);
    auto node = std::make_shared<Turtlecircle>("turtle_square");
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}